home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / __CHKSTK.ASM next >
Assembly Source File  |  1989-04-09  |  2KB  |  35 lines

  1.  
  2. ;__CHKSTK.ASM from the small model MS/C library.
  3. ; Disassembled by Jack A. Zucker 301-794-5950
  4.  
  5. ; on entry, ax contains the combined total of the size of the local
  6. ; variables to be allocated on the stack. Note that chars are rounded up
  7. ; to words by default.
  8.  
  9.  
  10. IGROUP:__chkstk:
  11. 50EF:0061 59             POP    CX                    ; IP from near call
  12. 50EF:0062 8BDC           MOV    BX,SP                 ; get top of stack
  13. 50EF:0064 2BD8           SUB    BX,AX                 ; Enough stack left?
  14. 10EF:0066 720A           JB     __chkstk+11 (0072)    ; NO
  15. 50EF:0068 3B1E6000       CMP    BX,[STKHQQ]           ; Cmp to Stack Bottom
  16. 50EF:006C 7204           JB     __chkstk+11 (0072)    ; Below Stack Bottom
  17. 50EF:006E 8BE3           MOV    SP,BX                 ; OK at this point
  18. 50EF:0070 FFE1           JMP    CX                    ; remember,CX = IP (dumb)
  19. 50EF:0072 E96801         JMP    __astkovr             ; Stack overflow routine
  20.  
  21. IGROUP:__astkovr:
  22. 50EF:01DD B112           MOV    CL,12                 ; number of bytes
  23. 50EF:01DF BA9E01         MOV    DX,019E               ; cs:19e "stack overflow"
  24. 50EF:01E2 32ED           XOR    CH,CH                 ; 0 out high byte
  25. 50EF:01E4 0E             PUSH   CS
  26. 50EF:01E5 1F             POP    DS                    ; set data = code
  27. 50EF:01E6 BB0200         MOV    BX,0002               ; stderr handle
  28. 50EF:01E9 B440           MOV    AH,40                 ; write file function
  29. 50EF:01EB CD21           INT    21                    ; write it!
  30. 50EF:01ED 16             PUSH   SS                    ; get data value back
  31. 50EF:01EE 1F             POP    DS                    ; small model ss=ds
  32. 50EF:01EF B8FF00         MOV    AX,00FF               ; exit errorlevel=255
  33. 50EF:01F2 50             PUSH   AX                    ; save on stack
  34. 50EF:01F3 E80E01         CALL   __exit                ; quit program
  35.